<?php
  class SCAction extends Action{
   Public function _initialize(){
 //  $config=C();
 //  dump($config);
   C('','BY_USER_SET_CONFIG');
   C('TMPL_DETECT_THEME',false);
   C('DEFAULT_THEME','');
 //  echo '<p>';
 //     $config=C();
 //  dump($config);
 //  exit();
   //C($config);
   // 初始化的时候检查用户权限
   
   $this->checklogin();
   }
    // 检查用户权限
  protected function checklogin() {
    // 这里是具体的检测代码
	if (!session('?user') || session('user')===''){
	  // redirect('/admin2/Login/index');
	   $this->redirect('Login/index');

	} 
 }

  Public function D_add($tb,$success,$error){
	 $Form=D($tb);
	if($Form->create()) {
        $result =   $Form->add();
        if($result) {
            $this->success((isset($success)?$success:'操作成功！'));
        }else{
            $this->error((isset($error)?$error:'写入错误！'));
        }
    }else{
        $this->error($Form->getError());
    }
  }
    Public function D_update($tb,$success,$error){
	 $Form=D($tb);
	if($Form->create()) {
        $result =   $Form->save();
        if($result) {
            $this->success((isset($success)?$success:'操作成功！'));
        }else{
            $this->error((isset($error)?$error:'写入错误！'));
        }
    }else{
        $this->error($Form->getError());
    }
  }
  }
?>